<html lang="zh">
<head>
    <title>修改用户信息</title>
    <style>
        tr {
            height: 30px;
        }

        td {
            padding: 10px;
            width: 100px;
        }
    </style>
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<form action="/udo/info/updatedo" method="post">
    {% csrf_token %}
    <input type="hidden" name="id" value="{{ user.id }}"/>
    <table style="margin-left: 50px;padding: 50px;border: 1px #ccc solid;width :600px">
        <tr>
            <td style="text-align:right">用户名:</td>
            <td style="text-align:left"><input type="text" name="name" value="{{ user.name }}"/></td>
        </tr>
        <tr>
            <td style="text-align:right;">性别:</td>
            <td style="text-align:left">
                <input type="radio" name="gender" id="gender1" value="1"/>男
                <input type="radio" name="gender" id="gender0" value="0"/>女
                {% if user.gender == 1 %}
                    <script>
                        $('#gender1').prop('checked', 'checked');
                    </script>
                {% else %}
                    <script>
                        $('#gender0').prop('checked', 'checked');
                    </script>
                {% endif %}
            </td>
        </tr>
        <tr>
            <td style="text-align:right">用户房间号:</td>
            <td>
                <select name="room_number" id="room_number">
                    {% for room in room_list %}
                        <option value="{{ room.room_number }}">{{ room.room_number }}</option>
                    {% endfor %}
                </select>
                <script>
                    var Number = {{ user.room.room_number }};
                    $("#room_number option[value='"+Number+"']").attr("selected", "selected");
                </script>
            </td>
        </tr>
        <tr>
            <td style="text-align:right">用户电话:</td>
            <td style="text-align:left"><input type="text" name="phone_number" value="{{ user.phone_number }}"/></td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center">
                <input type="submit" value="修改用户"/>
                <a href="/udo/info/delete{{ user.id }}">
                    <input type="button" value="删除用户"/>
                </a>
            </td>
        </tr>

    </table>
</form>
</body>
</html>
